home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
027a
/
calc14.zip
/
CALCHARD.PRG
< prev
next >
Wrap
Text File
|
1991-06-16
|
3KB
|
94 lines
// CalcHard.prg - Complex demo of the calculator
#include "inkey.ch"
Function CalcHard()
Local getlist:={}, nInteger, nDontWork, nFloating, cText, nAnother
Set Scoreboard OFF
CLS
Set Key K_ALT_O to Calculator
//This will cause F2 to multiply anything by 2
SetKey(K_F2,{|p,line,var,no| If(p="CALCULATOR", no * 2, NIL)})
//This will cause F3 to do a square root
SetKey(K_F3,{|p,line,var,no| If(p="CALCULATOR", Sqrt(no), NIL)})
//This will cause the $ dollar sign to set fixed decimals to 2
SetKey(Asc("$"),{|p|If(p="CALCULATOR", "F2", NIL)})
//This will cause the calc to call CalcProc() when beginning and when
// ending to display a personalized help screen.
CalcInit({|a,b,c,d,e,f,g|CalcProc(a,b,c,d,e,f,g)})
nInteger :=7
nDontWork:=6
nAnother:=-5
nFloating:=1.23
cText :=Space(8)
@ 6,5 Get nInteger
@ 7,5 Get nDontWork
@ 8,5 Get nAnother
@ 9,5 Get nFloating
@10,5 Get cText
@ 6,20 Say "< The integer will transfer to the calculator."
@ 7,20 Say "< You can disable the calculator on specific fields."
@ 8,20 Say "< Negative."
@ 9,20 Say "< Floating Point transfer and return (Ctrl-Enter)."
@10,20 Say "< Text pasting. (press Ctrl-Enter inside calculator."
@12,5 Say "Press ALT-O to access the calculator"
READ
Return NIL
Function CalcProc(cProc, nVer, cVar, nDisp, cDisp, cWhen, cColor)
* cProc = Procedure (always "CALCULATOR")
* nVer = Version number (10 through 13, for ver 1.0 through ver 1.3)
* cVar = Variable name of GET field called from
* nDisp = Numeric display of calculator
* cDisp = Character display of calculator
* cWhen = Either "INIT" when beginning calc or "END" when leaving calc
* cColor = Color when entering calculator
* * NOTE: Current color will always be "N/W", so use cColor
* * to determine color upon entry to calculator.
Static cSaveScreen
If cWhen = "INIT" //called going into the calculator
//First, if this variable is "nDontWork," then abort (no calculator)
If cVar = "NDONTWORK"
Return .T. // True = ABORT CALC
Endif
//Everything ok, change color to W+/B (if color display)
// Also, NO need to SAVE COLOR, calculator does that.
If(IsColor(),SetColor("W+/B"),NIL)
//Everything ok, save screen, popup help screen
cSaveScreen:=SaveScreen(0,29,5,51)
@ 0,29 to 5,51 Double
@ 1,30 Say " F2 = Display x 2 "
@ 2,30 Say " F3 = Square Root "
@ 3,30 Say " $ = Fix 2 decimals "
@ 4,30 Say " H = Calculator Help"
Else // cWhen = "END" //called going out of the calculator
RestScreen(0,29,5,51,cSaveScreen)
Endif
// (On INITIAL call from the calculator, if you return a character string,
// it will be "keyboarded" into the calculator (remember Set Typeahead).
Return "F3" //fix decimals to 3, only good on INITIAL call.